//
//  BaseModel.m
//  Gift Show
//
//  Created by 史兴宇 on 16/3/23.
//  Copyright © 2016年 史兴宇. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel

- (instancetype)initWithDic:(NSDictionary *)dic{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+ (instancetype)modelWithDic:(NSDictionary *)dic{
    return [[[[self class] alloc] initWithDic:dic] autorelease];
}

+ (NSMutableArray *)modelHandleWithArray:(NSArray *)array{
    // 创建Model数组
    NSMutableArray *arrModel = [NSMutableArray array];
    // 遍历字典
    for (NSDictionary *dic in array) {
        // 把字典转换成model
        BaseModel *model = [[self class] modelWithDic:dic];
        // 把model添加到model 数组中
        [arrModel addObject:model];
    }
    return arrModel;
}

//- (id)valueForUndefinedKey:(NSString *)key{
//    return nil;
//}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}

@end
